package com.zking.dao;

import com.zking.entity.User;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

/*
@Repository注解能够自动注入JPA的接口
JpaRepository<对应实体类, ID主键的类型>
1. 分页使用：不需要专门的方法，只要传递一个Pageable参数
*/
@Repository
public interface IUserDao extends JpaRepository<User, Integer> {
    // @Query(value = "select * from user2 where username like #{name}", nativeQuery = true)
    // List<User> selectName(String name);
    
    User findUserByPasswordAndUsernameOrderById(String name, String pass);
    Page<User> searchUsersByUsernameLikeAndMoneyBetween(
            Pageable pageable, String username, double min, double max);
}
